package cate.game.play.skill.active;

import cate.common.util.XT;
import cate.game.attr.FightAttr;
import cate.game.play.buff.BuffParam;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;

import java.util.List;

/**
 * 并额外再提升我方所有英雄（暗系英雄数量*3%）暴击，持续2回合
 */
public class 遗忘汤药AH extends ActiveHandler{

	private int buff;

	private FightAttr 属性;

	private List<Byte> 阵营;

	//buff=？？&属性=12:300&阵营=6
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		buff = args.getInt("buff", 0);
		属性 = new FightAttr(args.get("属性"));
		阵营 = args.getByteList("阵营");
	}

	@Override
	public void onSkillDone(SkillActionCtx action) {
		if(XT.isBlank(阵营)){
			return;
		}
		int num = (int) skill.owner.getFightTeam().getFightersAlive().stream().filter(f -> 阵营.contains(f.getCamp())).count();
		if (num <= 0) {
			return;
		}
		BuffParam param = new BuffParam().attrSet(属性.copy().scale(num));
		for (Fighter target : skill.owner.getFightTeam().getFightersAlive()) {
			target.buff.tryAddByTid(action, skill.owner, buff, param);
		}
	}
}
